package cn.edu.xmu.experiment.PulseComms.controller;

import cn.edu.xmu.experiment.PulseComms.until.TransApi;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;

@RestController
@RequestMapping("/translate")
public class TranslationController {

    @Autowired
    private TransApi transApi;

    @PostMapping
    public String translate(@RequestBody Map<String, String> request) {
        String text = request.get("text");
        return transApi.getTransResult(text, "en", "zh");
    }
}